
import React, { Component } from "react";

// 7. 页面组件中导入 store
import store from './store/storeIndex'

export default class Page1 extends Component {

    render() {

        // 8. 获取全局公共的数据
        const count = store.getState().count

        return <>
            <h1>Page1--- {count}</h1>
            <button onClick={() => {
                // 修改全局数据
                // 想办法触发 add 
                store.dispatch({
                    type: 'add'
                })
            }}>点击加 1</button>
            <button onClick={() => {
                store.dispatch({
                    type: 'addNum',
                    payload: 10
                })
            }}>加指定数</button>
        </>
    }
}